//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Windows.Data;
using OpenLS.Chart.UI.Internals;

namespace OpenLS.Chart.UI
{
    class MinMaxToInfoConverter : IMultiValueConverter
    {
        public MinMaxToInfoConverter(int maxItems)
        {
            this.maxItems = maxItems;
        }

        private readonly int maxItems;

        public int MaxItems
        {
            get { return maxItems; }
        }

        #region IMultiValueConverter Members

        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var lines = StrictConverter.Convert<ChartLines>(values[4]);
            if (lines == null)
                return null;
            var min = (double)values[0];
            var max = (double)values[1];
            var step = (double)values[2];
            return new ChartLineInfo(StrictConverter.Convert<Axis>(values[3]), lines, min, max, step);
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotSupportedException();
        }

        #endregion
    }
}
